#region License Revision: 0 Last Revised: 6/18/2008 11:00 AM
/******************************************************************************
Copyright (c) Microsoft Corporation.  All rights reserved.


This file is licensed under the Microsoft Public License (Ms-PL). A copy of the Ms-PL should accompany this file. 
If it does not, you can obtain a copy from: 

http://www.microsoft.com/resources/sharedsource/licensingbasics/publiclicense.mspx
******************************************************************************/
#endregion // License
using System;
using System.Windows.Browser;
using System.Diagnostics;
using System.Text;
using ScriptInterop;
using System.Globalization;

namespace VIEWS // Virtual Earth Wrapper
{
    /// <summary>
    /// Represents the scale of a 3D model with respect to the map.
    /// </summary>
    /// <remarks>
    /// Each axis represented by <c>VEModelScale</c> can be specified as a decimal value or as a 
    /// <see cref="VEModelScaleUnit"/> enumeration. To support reading and writing these values, 
    /// three properties have been implemented for each axis. <see cref="ScaleUnitX"/> allows the 
    /// X axis to be specified as a <see cref="VEModelScaleUnit"/> enumeration. <see cref="ScaleX"/> 
    /// allows the X axis to be specified as a decimal. <see cref="IsScaleUnitX"/> allows you 
    /// to determine how the value is currently stored and which property should be used to read 
    /// the current value.
    /// </remarks>
	public class VEModelScale : JSObject
	{
		/// <summary>String holding JavaScript class name</summary>
		private static string thisClass = "VEModelScale";
		
		/// <summary>Get the JavaScript class name</summary>
		/// <returns type="String">The class name used in JavaScript </returns>		
		public override string ClassName
		{
			get { return thisClass; }
		}

        #region Constructors
        /// <summary>Construct a C# wrapper from a ScriptObject</summary>
        public VEModelScale(ScriptObject so) : base(so) { }

        /// <summary>
        /// Initializes a new instance of the VEModelScale class using floating point values.
        /// </summary>
        /// <param name="scaleX">
        /// A floating-point value specifying the x-axis scale factor of a 3D model.
        /// </param>
        /// <param name="scaleY">
        /// A floating-point value specifying the y-axis scale factor of a 3D model.
        /// </param>
        /// <param name="scaleZ">
        /// A floating-point value specifying the z-axis scale factor of a 3D model.
        /// </param>
        public VEModelScale(double scaleX, double scaleY, double scaleZ)
        { ScriptObject = CreateClass(scaleX, scaleY, scaleZ); }

        /// <summary>
        /// Initializes a new instance of the VEModelScale class using a single floating point value.
        /// </summary>
        /// <param name="scale">
        /// A floating-point value specifying the scale factor of a 3D model.
        /// </param>
        public VEModelScale(double scale) : this(scale, scale, scale){}

        /// <summary>
        /// Initializes a new instance of the VEModelScale class using units of scale.
        /// </summary>
        /// <param name="scaleUnitX">
        /// A <see cref="VEModelScaleUnit"/> that indicates the X unit of scale.
        /// </param>
        /// <param name="scaleUnitY">
        /// A <see cref="VEModelScaleUnit"/> that indicates the Y unit of scale.
        /// </param>
        /// <param name="scaleUnitZ">
        /// A <see cref="VEModelScaleUnit"/> that indicates the Z unit of scale.
        /// </param>
        public VEModelScale(VEModelScaleUnit scaleUnitX, VEModelScaleUnit scaleUnitY, VEModelScaleUnit scaleUnitZ)
        {
            string sunitX = ScriptEnumConverter.ToString(scaleUnitX);
            string sunitY = ScriptEnumConverter.ToString(scaleUnitY);
            string sunitZ = ScriptEnumConverter.ToString(scaleUnitZ);
            ScriptObject = CreateClass(sunitX, sunitY, sunitZ);
        }

        /// <summary>
        /// Initializes a new instance of the VEModelScale class using a single unit of scale.
        /// </summary>
        /// <param name="scaleUnit">
        /// A <see cref="VEModelScaleUnit"/> that indicates the unit of scale.
        /// </param>
        public VEModelScale(VEModelScaleUnit scaleUnit) : this(scaleUnit, scaleUnit, scaleUnit){}
        #endregion // Constructors

        #region Public Properties

        /// <summary>
        /// Gets a value that indicates if the X scale is in <see cref="VEModelScaleUnit"/> units.
        /// </summary>
        /// <value>
        /// <c>true</c> if the X scale is in <see cref="VEModelScaleUnit"/> units; otherwise the scale is in decimal.
        /// </value>
        /// <remarks>
        /// If this property returns <c>true</c>, <see cref="ScaleUnitX"/> should be read to determine the model scale. 
        /// If this property returns <c>false</c>, <see cref="ScaleX"/> should be used instead.
        /// </remarks>
        public bool IsScaleUnitX
        {
            get { return GetProperty("X") is string; }
        }

        /// <summary>
        /// Gets a value that indicates if the Y scale is in <see cref="VEModelScaleUnit"/> units.
        /// </summary>
        /// <value>
        /// <c>true</c> if the Y scale is in <see cref="VEModelScaleUnit"/> units; otherwise the scale is in decimal.
        /// </value>
        /// <remarks>
        /// If this property returns <c>true</c>, <see cref="ScaleUnitY"/> should be read to determine the model scale. 
        /// If this property returns <c>false</c>, <see cref="ScaleY"/> should be used instead.
        /// </remarks>
        public bool IsScaleUnitY
        {
            get { return GetProperty("Y") is string; }
        }

        /// <summary>
        /// Gets a value that indicates if the Z scale is in <see cref="VEModelScaleUnit"/> units.
        /// </summary>
        /// <value>
        /// <c>true</c> if the Z scale is in <see cref="VEModelScaleUnit"/> units; otherwise the scale is in decimal.
        /// </value>
        /// <remarks>
        /// If this property returns <c>true</c>, <see cref="ScaleUnitZ"/> should be read to determine the model scale. 
        /// If this property returns <c>false</c>, <see cref="ScaleZ"/> should be used instead.
        /// </remarks>
        public bool IsScaleUnitZ
        {
            get { return GetProperty("Z") is string; }
        }

        /// <summary>
        /// Gets or sets a <see cref="VEModelScaleUnit"/> value specifying the X axis scale unit of a 3D model.
        /// </summary>
        /// <value>
        /// A floating-point value specifying the X axis scale unit of a 3D model.
        /// </value>
        /// <remarks>
        /// If the X axis scale is currently a decimal value, reading this property will raise an exception. 
        /// You can use the <see cref="IsScaleUnitX"/> property to determine the unit of measure.
        /// </remarks>
        public VEModelScaleUnit ScaleUnitX
        {
            get { return ScriptEnumConverter.ToModelScaleUnit(GetProperty<string>("X")); }
            set { SetProperty("X", ScriptEnumConverter.ToString(value)); }
        }

        /// <summary>
        /// Gets or sets a <see cref="VEModelScaleUnit"/> value specifying the Y axis scale unit of a 3D model.
        /// </summary>
        /// <value>
        /// A floating-point value specifying the Y axis scale unit of a 3D model.
        /// </value>
        /// <remarks>
        /// If the Y axis scale is currently a decimal value, reading this property will raise an exception. 
        /// You can use the <see cref="IsScaleUnitY"/> property to determine the unit of measure.
        /// </remarks>
        public VEModelScaleUnit ScaleUnitY
        {
            get { return ScriptEnumConverter.ToModelScaleUnit(GetProperty<string>("Y")); }
            set { SetProperty("Y", ScriptEnumConverter.ToString(value)); }
        }

        /// <summary>
        /// Gets or sets a <see cref="VEModelScaleUnit"/> value specifying the Z axis scale unit of a 3D model.
        /// </summary>
        /// <value>
        /// A floating-point value specifying the Z axis scale unit of a 3D model.
        /// </value>
        /// <remarks>
        /// If the Z axis scale is currently a decimal value, reading this property will raise an exception. 
        /// You can use the <see cref="IsScaleUnitZ"/> property to determine the unit of measure.
        /// </remarks>
        public VEModelScaleUnit ScaleUnitZ
        {
            get { return ScriptEnumConverter.ToModelScaleUnit(GetProperty<string>("Z")); }
            set { SetProperty("Z", ScriptEnumConverter.ToString(value)); }
        }

        /// <summary>
        /// Gets or sets a floating-point value specifying the X axis scale factor of a 3D model.
        /// </summary>
        /// <value>
        /// A floating-point value specifying the X axis scale factor of a 3D model.
        /// </value>
        /// <remarks>
        /// If the X axis scale is currently in <see cref="VEModelScaleUnit"/>s, reading this property will raise an exception.
        /// You can use the <see cref="IsScaleUnitX"/> property to determine the unit of measure.
        /// </remarks>
        public double ScaleX
        {
            get { return GetProperty<double>("X"); }
            set { SetProperty("X", value); }
        }

        /// <summary>
        /// Gets or sets a floating-point value specifying the Y axis scale factor of a 3D model.
        /// </summary>
        /// <value>
        /// A floating-point value specifying the Y axis scale factor of a 3D model.
        /// </value>
        /// <remarks>
        /// If the Y axis scale is currently in <see cref="VEModelScaleUnit"/>s, reading this property will raise an exception.
        /// You can use the <see cref="IsScaleUnitY"/> property to determine the unit of measure.
        /// </remarks>
        public double ScaleY
        {
            get { return GetProperty<double>("Y"); }
            set { SetProperty("Y", value); }
        }

        /// <summary>
        /// Gets or sets a floating-point value specifying the Z axis scale factor of a 3D model.
        /// </summary>
        /// <value>
        /// A floating-point value specifying the Z axis scale factor of a 3D model.
        /// </value>
        /// <remarks>
        /// If the Z axis scale is currently in <see cref="VEModelScaleUnit"/>s, reading this property will raise an exception.
        /// You can use the <see cref="IsScaleUnitZ"/> property to determine the unit of measure.
        /// </remarks>
        public double ScaleZ
        {
            get { return GetProperty<double>("Z"); }
            set { SetProperty("Z", value); }
        }
        #endregion // Public Properties
	};
}
